package com.itheima.service.impl;

import com.itheima.mapper.JobOptionMapper;
import com.itheima.pojo.JobOption;
import com.itheima.service.JobOptionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@Service
public class JobOptionServiceImpl implements JobOptionService {

    @Autowired
    private JobOptionMapper jobOptionMapper;

    /***
     * 统计职位人数
     * @return
     */
    @Override
    public JobOption getEmpJobData() {
        List<Map<String, Object>> list = jobOptionMapper.countEmpJobData();
        List<Object> pos = list.stream().map(m -> m.get("pom")).collect(Collectors.toList());
        List<Object> num = list.stream().map(m -> m.get("num")).collect(Collectors.toList());
        return new JobOption(pos, num);
    }

    @Override
    public List<Map> getEmpGenderData() {
        return jobOptionMapper.getEmpGenderData();
    }
}
